<template>
  <div class="product-management">
    <div class="header">
      <h2>商品管理</h2>
      <div class="header-actions">
        <button @click="showAddDialog = true" class="btn btn-primary">
          <i class="fas fa-plus"></i> 新增商品
        </button>
      </div>
    </div>

    <!-- 搜索过滤区域 -->
    <div class="filter-section">
      <div class="filter-row">
        <div class="filter-item">
          <label>关键词搜索:</label>
          <input
            v-model="searchParams.keyword"
            type="text"
            placeholder="商品名称"
            class="form-input"
            @keyup.enter="loadProductList"
          />
        </div>
        <div class="filter-item">
          <label>品牌:</label>
          <select v-model="searchParams.brandId" class="form-select">
            <option value="">全部品牌</option>
            <option v-for="brand in brandList" :key="brand.id" :value="brand.id">
              {{ brand.name }}
            </option>
          </select>
        </div>
        <div class="filter-item">
          <label>分类:</label>
          <select v-model="searchParams.categoryId" class="form-select">
            <option value="">全部分类</option>
            <option v-for="category in categoryList" :key="category.id" :value="category.id">
              {{ category.name }}
            </option>
          </select>
        </div>
        <div class="filter-item">
          <label>状态:</label>
          <select v-model="searchParams.status" class="form-select">
            <option value="">全部状态</option>
            <option value="1">上架</option>
            <option value="0">下架</option>
          </select>
        </div>
        <div class="filter-item">
          <label>热门:</label>
          <select v-model="searchParams.isHot" class="form-select">
            <option value="">全部</option>
            <option value="1">热门</option>
            <option value="0">普通</option>
          </select>
        </div>
        <div class="filter-actions">
          <button @click="loadProductList" class="btn btn-info">
            <i class="fas fa-search"></i> 搜索
          </button>
          <button @click="resetSearch" class="btn btn-secondary">
            <i class="fas fa-redo"></i> 重置
          </button>
        </div>
      </div>
    </div>

    <!-- 商品列表表格 -->
    <div class="table-container">
      <table class="data-table">
        <thead>
          <tr>
            <th width="60">ID</th>
            <th width="120">商品图片</th>
            <th width="200">商品信息</th>
            <th width="100">品牌</th>
            <th width="100">分类</th>
            <th width="120">价格</th>
            <th width="100">库存</th>
            <th width="80">销量</th>
            <th width="80">状态</th>
            <th width="80">热门</th>
            <th width="120">创建时间</th>
            <th width="180">操作</th>
          </tr>
        </thead>
        <tbody>
          <tr v-for="product in productList" :key="product.id">
            <td>{{ product.id }}</td>
            <td class="product-image">
              <img v-if="product.mainPicUrl" :src="product.mainPicUrl" :alt="product.name" class="product-thumb" />
              <div v-else class="no-image">
                <i class="fas fa-image"></i>
              </div>
            </td>
            <td class="product-info">
              <div class="product-details">
                <strong class="product-name">{{ product.name }}</strong>
                <p v-if="product.summary" class="product-summary">{{ product.summary }}</p>
                <div class="product-meta">
                  <span class="product-id">ID: {{ product.id }}</span>
                </div>
              </div>
            </td>
            <td>
              <span v-if="getBrandName(product.brandId)" class="brand-name">
                {{ getBrandName(product.brandId) }}
              </span>
              <span v-else class="no-brand">未设置</span>
            </td>
            <td>
              <span v-if="getCategoryName(product.categoryId)" class="category-name">
                {{ getCategoryName(product.categoryId) }}
              </span>
              <span v-else class="no-category">未设置</span>
            </td>
            <td class="price-info">
              <div class="price-current">¥{{ product.price.toFixed(2) }}</div>
              <div v-if="product.marketPrice" class="price-market">
                市场价: ¥{{ product.marketPrice.toFixed(2) }}
              </div>
            </td>
            <td class="stock-info">
              <span :class="['stock-number', { 'low-stock': product.stock < 10 }]">
                {{ product.stock }}
              </span>
              <button @click="showStockDialog(product)" class="stock-edit-btn">
                <i class="fas fa-edit"></i>
              </button>
            </td>
            <td class="sales-info">{{ product.salesCount }}</td>
            <td>
              <button 
                @click="toggleProductStatus(product)" 
                :class="['status-btn', product.status === 1 ? 'status-online' : 'status-offline']"
              >
                {{ product.status === 1 ? '上架' : '下架' }}
              </button>
            </td>
            <td>
              <button 
                @click="toggleProductHot(product)"
                :class="['hot-btn', product.isHot === 1 ? 'is-hot' : 'not-hot']"
              >
                <i :class="product.isHot === 1 ? 'fas fa-fire' : 'far fa-star'"></i>
                {{ product.isHot === 1 ? '热门' : '普通' }}
              </button>
            </td>
            <td>{{ formatDateTime(product.createdTime) }}</td>
            <td class="actions">
              <button @click="editProduct(product)" class="btn btn-sm btn-warning">
                <i class="fas fa-edit"></i> 编辑
              </button>
              <button @click="viewProduct(product)" class="btn btn-sm btn-info">
                <i class="fas fa-eye"></i> 查看
              </button>
              <button @click="deleteProductHandler(product)" class="btn btn-sm btn-danger">
                <i class="fas fa-trash"></i> 删除
              </button>
            </td>
          </tr>
          <tr v-if="productList.length === 0">
            <td colspan="12" class="no-data">暂无商品数据</td>
          </tr>
        </tbody>
      </table>
    </div>

    <!-- 分页组件 -->
    <div class="pagination-section">
      <div class="pagination-info">
        共 {{ total }} 条记录，第 {{ current }} / {{ Math.ceil(total / pageSize) }} 页
      </div>
      <div class="pagination-controls">
        <button
          @click="changePage(current - 1)"
          :disabled="current <= 1"
          class="btn btn-sm btn-secondary"
        >
          上一页
        </button>
        <span class="page-numbers">
          <button
            v-for="page in getPageNumbers()"
            :key="page"
            @click="changePage(page)"
            :class="['btn', 'btn-sm', page === current ? 'btn-primary' : 'btn-outline']"
          >
            {{ page }}
          </button>
        </span>
        <button
          @click="changePage(current + 1)"
          :disabled="current >= Math.ceil(total / pageSize)"
          class="btn btn-sm btn-secondary"
        >
          下一页
        </button>
      </div>
    </div>

    <!-- 新增/编辑商品弹窗 -->
    <div v-if="showAddDialog || showEditDialog" class="modal-overlay">
      <div class="modal-content product-form-modal" @click.stop>
        <div class="modal-header">
          <h3>{{ showEditDialog ? '编辑商品' : '新增商品' }}</h3>
          <button @click="closeDialog" class="close-btn">&times;</button>
        </div>
        <div class="modal-body">
          <form @submit.prevent="saveProduct">
            <div class="form-row">
              <div class="form-group">
                <label>商品名称 *</label>
                <input v-model="formData.name" type="text" required class="form-input" placeholder="请输入商品名称" />
              </div>
              <div class="form-group">
                <label>商品简介</label>
                <input v-model="formData.summary" type="text" class="form-input" placeholder="商品简短描述" />
              </div>
            </div>
            
            <div class="form-row">
              <div class="form-group">
                <label>品牌 *</label>
                <select v-model.number="formData.brandId" required class="form-select">
                  <option value="">请选择品牌</option>
                  <option v-for="brand in brandList" :key="brand.id" :value="brand.id">
                    {{ brand.name }}
                  </option>
                </select>
              </div>
              <div class="form-group">
                <label>分类 *</label>
                <select v-model.number="formData.categoryId" required class="form-select">
                  <option value="">请选择分类</option>
                  <option v-for="category in categoryList" :key="category.id" :value="category.id">
                    {{ category.name }}
                  </option>
                </select>
              </div>
            </div>
            
            <div class="form-row">
              <div class="form-group">
                <label>销售价格 *</label>
                <input v-model.number="formData.price" type="number" step="0.01" required class="form-input" placeholder="0.00" />
              </div>
              <div class="form-group">
                <label>市场价格</label>
                <input v-model.number="formData.marketPrice" type="number" step="0.01" class="form-input" placeholder="0.00" />
              </div>
              <div class="form-group">
                <label>库存数量</label>
                <input v-model.number="formData.stock" type="number" class="form-input" placeholder="0" />
              </div>
            </div>
            
            <div class="form-group">
              <label>主图片链接</label>
              <input v-model="formData.mainPicUrl" type="url" class="form-input" placeholder="请输入主图片链接" />
              <div v-if="formData.mainPicUrl" class="image-preview">
                <img :src="formData.mainPicUrl" alt="预览" />
              </div>
            </div>
            
            <div class="form-group">
              <label>图片链接列表</label>
              <textarea v-model="formData.picUrls" class="form-textarea" rows="3" placeholder="多个图片链接用逗号分隔"></textarea>
            </div>
            
            <div class="form-group">
              <label>商品描述</label>
              <textarea v-model="formData.description" class="form-textarea" rows="5" placeholder="请输入商品详细描述"></textarea>
            </div>
            
            <div class="form-row">
              <div class="form-group">
                <label>状态</label>
                <select v-model.number="formData.status" class="form-select">
                  <option :value="1">上架</option>
                  <option :value="0">下架</option>
                </select>
              </div>
              <div class="form-group">
                <label>热门标记</label>
                <select v-model.number="formData.isHot" class="form-select">
                  <option :value="0">普通</option>
                  <option :value="1">热门</option>
                </select>
              </div>
            </div>
            
            <div class="form-actions">
              <button type="button" @click="closeDialog" class="btn btn-secondary">取消</button>
              <button type="submit" :disabled="saving" class="btn btn-primary">
                {{ saving ? '保存中...' : '保存' }}
              </button>
            </div>
          </form>
        </div>
      </div>
    </div>

    <!-- 库存编辑弹窗 -->
    <div v-if="showStockEditDialog" class="modal-overlay">
      <div class="modal-content stock-modal" @click.stop>
        <div class="modal-header">
          <h3>编辑库存</h3>
          <button @click="closeStockDialog" class="close-btn">&times;</button>
        </div>
        <div class="modal-body">
          <div class="stock-current">
            <strong>{{ stockEditProduct?.name }}</strong>
            <p>当前库存: <span class="stock-value">{{ stockEditProduct?.stock }}</span></p>
          </div>
          <form @submit.prevent="updateStock">
            <div class="form-group">
              <label>新库存数量</label>
              <input v-model.number="newStock" type="number" required class="form-input" />
            </div>
            <div class="form-actions">
              <button type="button" @click="closeStockDialog" class="btn btn-secondary">取消</button>
              <button type="submit" :disabled="saving" class="btn btn-primary">
                {{ saving ? '更新中...' : '更新库存' }}
              </button>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue'
import { getProductList, createProduct, updateProduct, deleteProduct, updateProductStatus, updateProductHot, updateProductStock } from '@/api/product'
import { getBrandList } from '@/api/brand'
import { getCategoryList } from '@/api/category'
import type { Product, ProductQueryParams } from '@/types/product'
import type { Brand } from '@/types/brand'
import type { Category } from '@/types/category'

// 响应式数据
const productList = ref<Product[]>([])
const brandList = ref<Brand[]>([])
const categoryList = ref<Category[]>([])
const total = ref(0)
const current = ref(1)
const pageSize = ref(10)
const loading = ref(false)
const saving = ref(false)

// 弹窗状态
const showAddDialog = ref(false)
const showEditDialog = ref(false)
const showStockEditDialog = ref(false)
const currentProduct = ref<Product | null>(null)
const stockEditProduct = ref<Product | null>(null)
const newStock = ref(0)

// 搜索参数
const searchParams = reactive<ProductQueryParams>({
  keyword: '',
  brandId: undefined,
  categoryId: undefined,
  status: undefined,
  isHot: undefined,
  page: 1,
  size: 10
})

// 表单数据
const formData = reactive({
  id: 0,
  name: '',
  brandId: 0,
  categoryId: 0,
  summary: '',
  marketPrice: 0,
  price: 0,
  stock: 0,
  mainPicUrl: '',
  picUrls: '',
  status: 1,
  isHot: 0,
  description: ''
})

// 加载商品列表
const loadProductList = async () => {
  loading.value = true
  try {
    searchParams.page = current.value
    searchParams.size = pageSize.value
    const response = await getProductList(searchParams)
    productList.value = response.data.list
    total.value = response.data.total
  } catch (error) {
    console.error('加载商品列表失败:', error)
    alert('加载商品列表失败')
  } finally {
    loading.value = false
  }
}

// 加载品牌列表
const loadBrandList = async () => {
  try {
    const response = await getBrandList({ page: 1, size: 1000 })
    brandList.value = response.data.records
  } catch (error) {
    console.error('加载品牌列表失败:', error)
  }
}

// 加载分类列表
const loadCategoryList = async () => {
  try {
    const response = await getCategoryList({ page: 1, size: 1000 })
    categoryList.value = response.data.list
  } catch (error) {
    console.error('加载分类列表失败:', error)
  }
}

// 获取品牌名称
const getBrandName = (brandId: number) => {
  const brand = brandList.value.find(b => b.id === brandId)
  return brand?.name
}

// 获取分类名称
const getCategoryName = (categoryId: number) => {
  const category = categoryList.value.find(c => c.id === categoryId)
  return category?.name
}

// 重置搜索
const resetSearch = () => {
  Object.assign(searchParams, {
    keyword: '',
    brandId: undefined,
    categoryId: undefined,
    status: undefined,
    isHot: undefined
  })
  current.value = 1
  loadProductList()
}

// 分页切换
const changePage = (page: number) => {
  if (page < 1 || page > Math.ceil(total.value / pageSize.value)) return
  current.value = page
  loadProductList()
}

// 获取分页数字
const getPageNumbers = () => {
  const nums: number[] = []
  const totalPages = Math.ceil(total.value / pageSize.value)
  const start = Math.max(1, current.value - 2)
  const end = Math.min(totalPages, current.value + 2)
  
  for (let i = start; i <= end; i++) {
    nums.push(i)
  }
  return nums
}

// 编辑商品
const editProduct = (product: Product) => {
  currentProduct.value = product
  Object.assign(formData, {
    id: product.id,
    name: product.name,
    brandId: product.brandId,
    categoryId: product.categoryId,
    summary: product.summary || '',
    marketPrice: product.marketPrice || 0,
    price: product.price,
    stock: product.stock,
    mainPicUrl: product.mainPicUrl || '',
    picUrls: product.picUrls || '',
    status: product.status,
    isHot: product.isHot,
    description: product.description || ''
  })
  showEditDialog.value = true
}

// 查看商品详情
const viewProduct = (product: Product) => {
  // 这里可以实现商品详情查看功能
  alert(`查看商品详情: ${product.name}`)
}

// 删除商品
const deleteProductHandler = async (product: Product) => {
  if (!confirm(`确定要删除商品"${product.name}"吗？`)) return
  
  try {
    await deleteProduct(product.id)
    alert('删除成功')
    loadProductList()
  } catch (error) {
    console.error('删除商品失败:', error)
    alert('删除商品失败')
  }
}

// 切换商品状态
const toggleProductStatus = async (product: Product) => {
  const newStatus = product.status === 1 ? 0 : 1
  const action = newStatus === 1 ? '上架' : '下架'
  
  try {
    await updateProductStatus(product.id, newStatus)
    product.status = newStatus
    alert(`${action}成功`)
  } catch (error) {
    console.error(`${action}失败:`, error)
    alert(`${action}失败`)
  }
}

// 切换热门标记
const toggleProductHot = async (product: Product) => {
  const newHot = product.isHot === 1 ? 0 : 1
  const action = newHot === 1 ? '设为热门' : '取消热门'
  
  try {
    await updateProductHot(product.id, newHot)
    product.isHot = newHot
    alert(`${action}成功`)
  } catch (error) {
    console.error(`${action}失败:`, error)
    alert(`${action}失败`)
  }
}

// 显示库存编辑弹窗
const showStockDialog = (product: Product) => {
  stockEditProduct.value = product
  newStock.value = product.stock
  showStockEditDialog.value = true
}

// 更新库存
const updateStock = async () => {
  if (!stockEditProduct.value) return
  
  saving.value = true
  try {
    await updateProductStock(stockEditProduct.value.id, newStock.value)
    stockEditProduct.value.stock = newStock.value
    alert('库存更新成功')
    closeStockDialog()
    loadProductList()
  } catch (error) {
    console.error('更新库存失败:', error)
    alert('更新库存失败')
  } finally {
    saving.value = false
  }
}

// 关闭库存弹窗
const closeStockDialog = () => {
  showStockEditDialog.value = false
  stockEditProduct.value = null
  newStock.value = 0
}

// 保存商品
const saveProduct = async () => {
  saving.value = true
  try {
    const productData = {
      name: formData.name,
      brandId: formData.brandId,
      categoryId: formData.categoryId,
      summary: formData.summary,
      marketPrice: formData.marketPrice || undefined,
      price: formData.price,
      stock: formData.stock,
      mainPicUrl: formData.mainPicUrl,
      picUrls: formData.picUrls,
      status: formData.status,
      isHot: formData.isHot,
      description: formData.description
    } as any

    if (showEditDialog.value && currentProduct.value) {
      await updateProduct(currentProduct.value.id, productData)
      alert('更新成功')
    } else {
      await createProduct(productData)
      alert('创建成功')
    }
    
    closeDialog()
    loadProductList()
  } catch (error) {
    console.error('保存商品失败:', error)
    alert('保存商品失败')
  } finally {
    saving.value = false
  }
}

// 关闭弹窗
const closeDialog = () => {
  showAddDialog.value = false
  showEditDialog.value = false
  currentProduct.value = null
  Object.assign(formData, {
    id: 0,
    name: '',
    brandId: 0,
    categoryId: 0,
    summary: '',
    marketPrice: 0,
    price: 0,
    stock: 0,
    mainPicUrl: '',
    picUrls: '',
    status: 1,
    isHot: 0,
    description: ''
  })
}



// 格式化日期时间
const formatDateTime = (dateStr: string) => {
  return new Date(dateStr).toLocaleString('zh-CN')
}

// 页面加载时获取数据
onMounted(() => {
  loadProductList()
  loadBrandList()
  loadCategoryList()
})
</script>

<style scoped>
.product-management {
  padding: 20px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.header h2 {
  margin: 0;
  color: #333;
}

.header-actions {
  display: flex;
  gap: 10px;
}

.filter-section {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 20px;
}

.filter-row {
  display: flex;
  gap: 20px;
  align-items: end;
  flex-wrap: wrap;
}

.filter-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.filter-item label {
  font-weight: 500;
  color: #555;
  font-size: 12px;
}

.form-input, .form-select, .form-textarea {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}

.filter-item .form-input,
.filter-item .form-select {
  width: 150px;
}

.table-container {
  background: white;
  border-radius: 8px;
  overflow-x: auto;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1200px;
}

.data-table th {
  background: #f8f9fa;
  padding: 10px 8px;
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid #dee2e6;
  font-size: 12px;
}

.data-table td {
  padding: 10px 8px;
  border-bottom: 1px solid #dee2e6;
  vertical-align: middle;
  font-size: 12px;
}

.product-image {
  text-align: center;
}

.product-thumb {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid #e9ecef;
}

.no-image {
  width: 60px;
  height: 60px;
  background: #f8f9fa;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6c757d;
  border: 1px solid #e9ecef;
  margin: 0 auto;
}

.product-info .product-name {
  display: block;
  color: #333;
  margin-bottom: 3px;
  font-size: 13px;
  line-height: 1.3;
}

.product-summary {
  color: #666;
  font-size: 11px;
  margin: 3px 0;
  line-height: 1.2;
}

.product-meta {
  font-size: 10px;
  color: #999;
}

.brand-name, .category-name {
  background: #e9ecef;
  padding: 2px 6px;
  border-radius: 8px;
  font-size: 11px;
  color: #495057;
}

.no-brand, .no-category {
  color: #999;
  font-style: italic;
  font-size: 11px;
}

.price-info .price-current {
  font-weight: 600;
  color: #e74c3c;
  font-size: 13px;
}

.price-info .price-market {
  font-size: 10px;
  color: #999;
  text-decoration: line-through;
}

.stock-info {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  vertical-align: middle;
}

.stock-number {
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  background: #d4edda;
  color: #155724;
}

.low-stock {
  background: #f8d7da !important;
  color: #721c24 !important;
}

.stock-edit-btn {
  background: none;
  border: none;
  color: #007bff;
  cursor: pointer;
  font-size: 11px;
  padding: 2px;
}

.status-btn, .hot-btn {
  padding: 3px 8px;
  border: none;
  border-radius: 12px;
  font-size: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.status-online {
  background: #28a745;
  color: white;
}

.status-offline {
  background: #dc3545;
  color: white;
}

.is-hot {
  background: #ff6b35;
  color: white;
}

.not-hot {
  background: #6c757d;
  color: white;
}

.actions .btn {
  margin-right: 3px;
  margin-bottom: 3px;
}

.btn {
  padding: 6px 10px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  transition: all 0.2s;
}

.btn-sm {
  padding: 3px 6px;
  font-size: 10px;
}

.btn-primary {
  background: #007bff;
  color: white;
}

.btn-secondary {
  background: #6c757d;
  color: white;
}

.btn-info {
  background: #17a2b8;
  color: white;
}

.btn-warning {
  background: #ffc107;
  color: #212529;
}

.btn-success {
  background: #28a745;
  color: white;
}

.btn-danger {
  background: #dc3545;
  color: white;
}

.btn-outline {
  background: transparent;
  border: 1px solid #ddd;
  color: #333;
}

.pagination-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-numbers {
  display: flex;
  gap: 5px;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.product-form-modal {
  width: 90%;
  max-width: 900px;
}

.stock-modal {
  width: 90%;
  max-width: 400px;
}

.modal-content {
  background: #ffffff;
  border-radius: 4px;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid #e8e8e8;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #f0f0f0;
  background: #fafafa;
}

.modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
  color: #333333;
}

.close-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #999999;
  padding: 4px;
  line-height: 1;
  transition: color 0.2s;
}

.close-btn:hover {
  color: #666666;
}

.modal-body {
  padding: 20px;
  background: #ffffff;
}

.form-row {
  display: flex;
  gap: 20px;
  margin-bottom: 18px;
}

.form-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-weight: 400;
  color: #666666;
  font-size: 14px;
}

.form-row .form-input,
.form-row .form-select {
  width: 100%;
}

.image-preview {
  margin-top: 10px;
}

.image-preview img {
  width: 100px;
  height: 100px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid #ddd;
}

.stock-current {
  margin-bottom: 20px;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 8px;
}

.stock-value {
  font-weight: 600;
  color: #007bff;
}

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #f0f0f0;
}

.no-data {
  text-align: center;
  color: #666;
  font-style: italic;
  padding: 40px;
}
</style> 